/**
 * 
 */
var url = getRoot() + "/websql/toSearchSqlLog";
$(document).ready(function() {
	var ltsTable = $("#sqlquery-table-container").ltsTable({
		url : url,
		templateId : 'sqlquery-table'
	});

	LTS.colFormatter.esResultFormat = function(v, row) {
		return esTranslateResultFormat(row);
	}

	$(document).on("click", "#searchBtn", function() {
		var params = {};
		$.each($('#optlog-query-form').find(".form-control"), function() {
			var name = $(this).attr("name");
			if (isNull(name)) {
				return true;
			}
			var value = $(this).val();
			if (!isNull(value)) {
				value = $.trim(value);
				params[name] = value;
			}
		});
		params['startTime'] = $("#startDatetime").val();
		params['endTime'] = $("#endDatetime").val();
		var environValue = $("#environValue").val();
		if (environValue == 0) {
			swal('失败', '请选择环境', 'error');
			return;
		} else {
			params['environValue'] = environValue;
		}
		ltsTable.post(params, 1);
	});

	/* $("#searchBtn").trigger("click"); */
});
function esTranslateResultFormat(data) {
	var result = data['result'];
	var transResult = result.replace(/<tr/g, "").replace(/>/g, '').replace(
			/<td/g, '').replace(/<\/td/g, '').replace(/<\/tr/g, '');
	return transResult;
}